package com.lxq.action;

import com.lxq.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.ModelAndViewDefiningException;

import javax.servlet.http.HttpSession;

@Controller
public class useraction {

/*
@RequestMapping("/login")
    public ModelAndView login(User user){
        ModelAndView mv=new ModelAndView();
        mv.addObject("user",user);
        mv.setViewName("welcome");
        return mv;
    }*/

    //控制器方法相互调用
    //httpsession的使用
    @RequestMapping("/login")
    public String login(User user, HttpSession session) {
        session.setAttribute("user", user);
        return "redirect:list.do";
    }

    @RequestMapping("list")
    public String list(User user, HttpSession session) {
        User u = (User) session.getAttribute("user");
        System.out.println(u);
        return "welcome";
    }
    @RequestMapping("/getpid")
    public String getbyid(@RequestParam("pid") Integer id) {
        System.out.println("-------"+id);
        return null;
    }
}
